// 404 中间件
const notFoundMiddleware = (req, res, next) => {
  res.status(404).json({ msg: 'Not Found' });
};

// 500 中间件
const errorMiddleware = (err, req, res, next) => {
  console.error(err, '500');
  res.status(500).json({ msg: 'Internal Server Error' });
};

// 200成功中间件
const successMiddleware = (req, res, next) => {
  res.success = (data) => {
    // console.log("🚀 ~ successMiddleware ~ data:", data)
    res.json({ code: 0, msg: 'success', ...data });
  };
  next();
};

module.exports = { notFoundMiddleware, errorMiddleware, successMiddleware };